{% extends 'food/base.html' %}

{% block content %}
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">类别管理</h5>
        <a href="{% url 'admin:food_category_add' %}" class="btn btn-primary btn-sm">添加类别</a>
    </div>
    <div class="card-body">
        <div class="row">
            {% for category in categories %}
            <div class="col-md-4 mb-3">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">{{ category.name }}</h5>
                        <p class="card-text">{{ category.description|truncatewords:30 }}</p>
                        <a href="{% url 'admin:food_category_change' category.id %}" class="btn btn-sm btn-outline-primary">编辑</a>
                    </div>
                </div>
            </div>
            {% empty %}
            <div class="col-12">
                <p class="text-center">暂无类别数据</p>
            </div>
            {% endfor %}
        </div>
    </div>
</div>
{% endblock %}
